package com.ewzj.bigdata.mvp.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.ewzj.bigdata.R;
import com.ewzj.bigdata.mvp.model.entity.resbean.BannerBean;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.http.imageloader.glide.ImageConfigImpl;
import com.jess.arms.utils.ArmsUtils;
import com.zhouwei.mzbanner.holder.MZViewHolder;

/**
 * Author:zhangjing
 * Time:2018/2/1  下午8:37
 * Name: this is BannerViewHolder
 * Email:zhangjingworkmol@163.com
 */

public class BannerViewHolder implements MZViewHolder<BannerBean> {
    private ImageLoader imageLoader;
    private ImageView imageView;
    @Override
    public View createView(Context context) {
        View view=LayoutInflater.from(context).inflate(R.layout.card_banner_item,null,false);
        imageView=view.findViewById(R.id.imageView);
        imageLoader= ArmsUtils.obtainAppComponentFromContext(context).imageLoader();
        return view;
    }

    @Override
    public void onBind(Context context, int i, BannerBean newBean) {
        imageLoader.loadImage(context, ImageConfigImpl.builder().transformation(new RoundedCorners(5))
        .url(newBean.getThumb()).imageView(imageView).build());
    }
}
